import {
  request
} from '../../request/index'
import regeneratorRuntime from '../../lib/runtime/runtime'

// pages/video/index.js
Page({

  data: {
    //导航标签
    videoTags: [],
    //导航标识
    navId: 58100,
    videoList: [],
    isTriggered:false

  },

  onLoad: function (options) {
    this.getVideoTags()
    this.getVideoList(this.data.navId)
  },

  //获取视频标签
  async getVideoTags() {
    let {
      data: {
        data
      }
    } = await request({
      url: "/video/group/list"
    })
    this.setData({
      videoTags: data.splice(0, 14),
    })
  },
  //切换tab
  handleItemTap(e) {
    let navId = e.currentTarget.id;
    this.setData({
      navId: navId * 1,
      videoList: []
    })

    wx.showLoading({
      title: "加载中",
      mask: true,
    });

    this.getVideoList(this.data.navId)
  },

  //获取视频列表
  async getVideoList(id) {
    let {
      data: {
        datas
      }
    } = await request({
      url: "/video/group",
      data: {
        id: id
      }
    })

    wx.hideLoading();
    
    this.setData({
      videoList: datas,
      isTriggered:false
    })
  },

  //下拉刷新
  handleRefresher() {
    this.getVideoList(this.data.navId)
  },

  onShareAppMessage:function({from}){
    return{
      title:"神级现场",
      page:"/pages/video/index",
    }
    
  }





})